package com.baosight.sczx.common.zm.cInterface;

import java.util.HashMap;
import java.util.List;

import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.core.threadlocal.UserSession;
import com.baosight.iplat4j.dao.Dao;
import com.baosight.sczx.common.zm.cInterface.CmesConstants;
import com.baosight.sczx.zm.domain.ZM91;


/**
 * 首页设置
 * <p>Title: IndexConfiger.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 高强
 * @version 1.0
 * <pre>Histroy:
 *          2012-11-12 上午10:46:38  高强  Create
 *</pre>
 */
public class IndexConfiger {
	
	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	private static IndexConfiger instance = new IndexConfiger();
	private static ZM91 zm91;
	
	private IndexConfiger(){
		initData();//当第一次使用的时候初始化
	}
	
	@SuppressWarnings("unchecked")
	private void initData(){
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("fdUserId",UserSession.getLoginName());
		List<ZM91> _list = dao.query("ZM91.query", map);
		if(_list.size() < 1) {
			zm91 = null;
		}
		else {
			zm91 = _list.get(0);
		}
		CmesConstants.INDEXCONFIGER = 0;
	}
	
	/**
	 * 获得是否是领导
	 * <p>Function: getFdVlaue</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-11-18下午02:50:20 高强
	 * </p>
	 *
	 */
	public String getIsLeader(){
		String _temp = new String("是");//默认为“是”，启动
		if(zm91 != null) {
			_temp = zm91.getFdValue();
		}
		
		return _temp;
	}
	
	/**
	 * 得到对象的唯一句柄
	 * <p>Function: getInstance</p>
	 * <p>Description: </p>
	 * <p>return value:SystemSettingCD</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-11-18下午02:50:20 高强
	 * </p>2
	 *
	 */
	public static IndexConfiger getInstance(){
		if(CmesConstants.INDEXCONFIGER == 1) {
			instance = new IndexConfiger();
		}
		
		return instance;
	}
}
